// TextDetector.h: interface for the CTextDetector class.
//
//////////////////////////////////////////////////////////////////////

#ifndef OBJECT_DETECTOR_H
#define OBJECT_DETECTOR_H

#include "mcRaster.h"
#include "mcRasterColor.h"
#include "AClassifier.h"
#include "HarrFeatures.h"
#include "CvFaceDetector.h"

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
class CObjectDetector
{
public:
	// construction & destruction
	CObjectDetector();
	virtual ~CObjectDetector();
	virtual void Free(void);
	virtual void Empty(void);

	// load all the trained classifiers from the file
	virtual bool	LoadClassifiers(const char* strFileName);
	// run the detector
	Raster<uchar>&	GreyImage(void) {return *pimage_org_grey;};

	// output the results
	virtual int		NumDetectedRect(void){return list_detected_candidates.Num();};
	virtual bool	GetFirstDetectedRect(RectOfInterest &roi){return list_detected_candidates.GetFirst(roi);};
	virtual bool	GetNextDetectedRect(RectOfInterest &roi){return list_detected_candidates.GetNext(roi);};
	virtual LinkList<RectOfInterest>&	DetectedRect(void){return list_detected_candidates;};

protected:
	virtual int		MergeTextRects(vrect& vRects, vfloat &vWeights);
	virtual int		MergeFaceRects(vrect &vRects, vfloat &vWeights);

protected:
	CAClassifier				*m_pcClassifier;
	Raster<uchar>				*pimage_org_grey;
	Raster_Color<uchar>			*pimage_org_color;
	LinkList<RectOfInterest>	list_detected_candidates;
};


//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
class CTextDetector : public CObjectDetector
{
public:
	CTextDetector();
	virtual ~CTextDetector();
};


//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
class CFaceDetector  : public CObjectDetector
{
public:
	CFaceDetector();
	virtual ~CFaceDetector();
	
	virtual void	LoadCVDetector(void);

protected:
	virtual int		PostProcessing(Raster<uchar> &src, vrect &vRects, vfloat &vWeights);

protected:
	CHarrFeatures	m_harrs;
	CvHidHaarClassifierCascade cv_face_detector;
};



#endif
